

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bugly/flutter_bugly.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:oktoast/oktoast.dart';
import 'package:oral_cloud/config/storage_manager.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';
import 'config/router_manger.dart' as my_router;
import 'generated/l10n.dart';
const platform = const MethodChannel('com.meyer.flutter/main');
void main() async{

  WidgetsFlutterBinding.ensureInitialized();
  await FlutterDownloader.initialize(debug: true);
  await StorageManager.init();
  FlutterBugly.postCatchedException((){
    runApp(App());
  });
  FlutterBugly.init(androidAppId: '799ddd3be2');
  if (Platform.isAndroid) {
    FlutterBugly.checkUpgrade();
      // 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后，是为了在渲染后进行set赋值，覆盖状态栏，写在渲染之前MaterialApp组件会覆盖掉这个值。
    SystemUiOverlayStyle systemUiOverlayStyle =
    SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
   }

}





class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    StorageManager.platform=Theme.of(context).platform;
    return OKToast(
      child: MaterialApp(
      theme: ThemeData(
          primaryColor: Color(0xFF00BB7A),
          accentColor: Color(0xFFFFFFFF)
      ),
      navigatorKey: my_router.Router.navigatorState,
      initialRoute: my_router.RouteName.splash,
      onGenerateRoute: my_router.Router.generateRoute,
      localizationsDelegates: const [
        S.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        RefreshLocalizations.delegate,
      ],
      locale: Locale('zh',''),
      localeResolutionCallback:(Locale locale, Iterable<Locale> supportedLocales) {
        return Locale('zh','');
      },


    ),);
  }
}


